layui.define([ 'form', 'laydate', 'table', ], function(exports) {
	var form = layui.form;
	var table = layui.table;
	var index = layui.index;

	var view = {
		init : function() {

			this.initSubmit();
		},
		initSubmit : function() {
			$(document).on("click", ".follow_01", function() {				
				var collect = $('.follow_01').attr('collect');
				var sellerId = $(".sellerId_input").val();				
				var stv = $(this);
				var num = $('.follow_01').attr('num');
				if(collect == "true"){
					var url = '/user/delCollectSeller.do';
				}else{
					var url = '/user/doCollectSeller.do';
				}
				doAjax(url, 'post', {'sellerId':sellerId}, function(ret){
					if(ret.code=='1'){
						!stv.find("s").hasClass('atv')?stv.find("s").addClass("atv"):stv.find("s").removeClass("atv")
						if(collect=="false"){
							$('.follow_01').attr('collect','true');
							var collectnum = Number(num)+1;
							$('.num').html(collectnum);
							$('.follow_01').attr('num',collectnum);
							$.alert("success","关注成功",1);
						}else {
							$('.follow_01').attr('collect','false');
							var collectnum = Number(num)-1;
							$('.num').html(collectnum);
							$('.follow_01').attr('num',collectnum);
							$.alert("success","取消成功",1);
						}
					}else{
						if(collect){
							$.alert("error","关注失败",1);
						}else {
							$.alert("error","取消失败",1);
						}
					}
				});
			});

		}
	}
	exports('providerDetails', view);
});